

local obj = {}

local begin_time = 0
local delay_global = 0
local timer = nil
local is_open = false
local secent = 0
local flash_timer = tmr.create()
flash_timer:register(1000, tmr.ALARM_AUTO, function ()
    secent = secent + 1
end)
flash_timer:start()

function obj:SetTimeOut(func, delay)
    delay_global = delay
    if is_open then
        timer:stop()
        timer:unregister()
        timer = nil
    end
    begin_time = secent
    timer = tmr.create()
    timer:register(delay * 1000, tmr.ALARM_SINGLE, function ()
        func()
        is_open = false
    end )
    timer:start()
    is_open = true
end

function obj:GetSecent()
    return secent
end

function obj:GetStatus()

    if is_open then
        return true, delay_global - (secent - begin_time)
    end
    return false, nil
end



return obj